﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Runtime.Serialization;
using System.Collections.ObjectModel;

namespace Kaesoft.Hospedaje.Entities
{
    [DataContract]
    [KnownType(typeof(CatalogoSummary))]
    public partial class Arbol : INotifyComplexPropertyChanging, INotifyPropertyChanged
    {
        private ObservableCollection<Arbol> _arbolHijo;
        private Object _entidad;
        public event EventHandler onSelectedChanged;

        [DataMember]
        public Object Entidad
        {
            get { return _entidad; }
            set
            {
                OnComplexPropertyChanging();
                _entidad = value;
                OnPropertyChanged("Entidad");
            }
        }

        [DataMember]
        public ObservableCollection<Arbol> ArbolHijo
        {
            get { return _arbolHijo; }
            set
            {
                if (value != _arbolHijo)
                {
                    OnComplexPropertyChanging();
                    _arbolHijo = value;
                    OnPropertyChanged("ArbolHijo");
                }
            }
        }

        private bool _seleccionado;

        [DataMember]
        public bool Seleccionado
        {
            get
            {
                return _seleccionado;
            }
            set
            {
                if (_seleccionado != value)
                {
                    _seleccionado = value;
                    OnPropertyChanged("Seleccionado");
                    OnSelectedChanged();
                }
            }
        }

        private bool _esCatalogo;

        [DataMember]
        public bool EsCatalogo
        {
            get
            {
                return _esCatalogo;
            }
            set
            {
                if (_esCatalogo != value)
                {
                    _esCatalogo = value;
                    OnPropertyChanged("EsCatalogo");
                }
            }
        }

        private int _nivel;

        [DataMember]
        public int Nivel
        {
            get
            {
                return _nivel;
            }
            set
            {
                if (_nivel != value)
                {
                    _nivel = value;
                    OnPropertyChanged("Nivel");
                }
            }
        }

        Guid _id;

        [DataMember]
        public Guid Id
        {
            get
            {
                return _id;
            }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged("Id");
                }
            }
        }

        private bool _seleccionadoCortar;

        [DataMember]
        public bool SeleccionadoCortar
        {
            get
            {
                return _seleccionadoCortar;
            }
            set
            {
                if (_seleccionadoCortar != value)
                {
                    _seleccionadoCortar = value;
                    OnPropertyChanged("SeleccionadoCortar");
                }
            }
        }

        private bool  _enabledSeleccion = true;

        [DataMember]
        public bool EnabledSeleccion
        {
            get
            {
                return _enabledSeleccion;
            }
            set
            {
                if (_enabledSeleccion != value)
                {
                    _enabledSeleccion = value;
                    OnPropertyChanged("EnabledSeleccion");
                }
            }
        }

        public void OnSelectedChanged()
        {
           if (onSelectedChanged != null)
           {
              onSelectedChanged(this, new EventArgs());
           }
        }
    }
}
